<%@ page language="java" contentType="text/html; charset=UTF-8"
         import="com.baichang.framework.utils.FileUtils"
         pageEncoding="UTF-8" %>
<%@ page import="com.baidu.ueditor.ActionEnter" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%

    request.setCharacterEncoding("utf-8");
    response.setHeader("Content-Type", "text/html");

    String projectName = request.getContextPath();
    if (projectName.startsWith("/")) {
        projectName = projectName.substring(1, projectName.length());
    }
    String rootPath = application.getRealPath("/");
    String originalPath = "";
    if (rootPath.length() > 0) {
        originalPath = rootPath + request.getRequestURI().substring(request.getContextPath().length());
    } else {
        originalPath = rootPath + request.getRequestURI();
    }
    originalPath = originalPath.replace("controller.jsp", "config.json");
    String json = FileUtils.readTextFile(originalPath);
    json = json.replace("{projectName}", projectName);
    FileUtils.writeString2File(originalPath, json);
    out.write(new ActionEnter(request, rootPath).exec());

%>